<?php
class Ecore_Cache_Ddht
{
	public $server = null;

	public function __construct($server)
	{
		$this->server = $server;
	}	

	public function delete($key)
	{		
		$r = $this->server->delete($key);
		return $r;
	}

	public function addPrefix($strKey, $strId)
	{
		$arrId = explode(',', $strId);
		for($i = 0; $i < count($arrId); $i++) {
			$arrId[$i] = $strKey . $arrId[$i];
		}
		return $arrId;
	}
	/**ADMIN*/
	public function deleteAdminById($intAdminId) {
		$this->delete(BACKEND_ADMIN_GETPERMISSIONBYADMIN . $intAdminId);
		$this->delete(BACKEND_ADMIN_GET . $intAdminId);
	}
	public function deleteAdminByUsername($strUsername) {
		$this->delete(BACKEND_ADMIN_GETINFOBYUSERNAME . $strUsername);
	}
	public function deleteAdPermission($intAdminId, $intSectionId) {
		$this->delete(BACKEND_ADMIN_GETPERMISSION . $intAdminId . $intSectionId);
	}
	/** CONTENT */
	public function deleteContentByPage($strAction) {
		$this->delete(CONTENT_GETBYPAGE . $strAction . '1');
		$this->delete(CONTENT_GETBYPAGE . $strAction . '2');
	}
	/***/

	public function deleteCommonSeo($strController, $strAction) {
		$this->delete(COMMON_GETSEO . $strController . $strAction);
	}
	public function deleteCategory($intLanguage, $intType, $intParentId=0) {
		if($intParentId > 0) {
			$this->delete(COMMON_GETCATEGORY . $intLanguage . $intType . '0');
		}
		$this->delete(COMMON_GETCATEGORY . $intLanguage . $intType . $intParentId);
	}
	public function deleteCategoryById($intCategoryId) {
		$this->delete(COMMON_GETCATEGORYBYID . $intCategoryId);
	}
	public function deleteBackground($intLanguage, $intType) {
		if($intLanguage > 0) {
			$this->delete(COMMON_GETBACKGROUND . '0' . $intType);
		}
		$this->delete(COMMON_GETBACKGROUND . $intLanguage . $intType);
	}
	/** EDUCATION */
	public function deleteEducation($intEducateId) {
		$this->delete(EDUCATION_GET . $intEducateId);
		
	}
	public function deleteEducateForCategory($intCategoryId, $intSubId=0) {
		$this->delete(EDUCATION_GETTOPE . '00');
		$this->delete(EDUCATION_GETTOPE . $intCategoryId . '0');
		if($intSubId > 0) {
			$this->delete(EDUCATION_GETTOPE . $intCategoryId . $intSubId);
		}
	}
	public function deleteEducationU($intEducateId, $intType) {
		if($intType >= 0) {
			$this->delete(EDUCATION_GETEDUCATIONU . $intEducateId . '-1');
		}
		$this->delete(EDUCATION_GETEDUCATIONU . $intEducateId . $intType);
		
	}
	/** SHARE */
	public function deleteBoard($intCategoryId, $intSubId, $intUserId=0) {
		if($intUserId > 0) {
			$this->delete(SHARE_GETALLBOARD . $intUserId . $intCategoryId . $intSubId);
		}
		//no cate + sub
		$this->delete(SHARE_GETALL . '000');
		$this->delete(SHARE_GETALL . '100');
		$this->delete(SHARE_GETALL . '200');
		$this->delete(SHARE_GETALL . '300');
		$this->delete(SHARE_GETALL . '400');
		$this->delete(SHARE_GETALL . '500');
		//cate
		$this->delete(SHARE_GETALL . '0' . $intCategoryId . '0');
		$this->delete(SHARE_GETALL . '1' . $intCategoryId . '0');
		$this->delete(SHARE_GETALL . '2' . $intCategoryId . '0');
		$this->delete(SHARE_GETALL . '3' . $intCategoryId . '0');
		$this->delete(SHARE_GETALL . '4' . $intCategoryId . '0');
		$this->delete(SHARE_GETALL . '5' . $intCategoryId . '0');
		//cate + sub
		$this->delete(SHARE_GETALL . '0' . $intCategoryId . $intSubId);
		$this->delete(SHARE_GETALL . '1' . $intCategoryId . $intSubId);
		$this->delete(SHARE_GETALL . '2' . $intCategoryId . $intSubId);
		$this->delete(SHARE_GETALL . '3' . $intCategoryId . $intSubId);
		$this->delete(SHARE_GETALL . '4' . $intCategoryId . $intSubId);
		$this->delete(SHARE_GETALL . '5' . $intCategoryId . $intSubId);
		//home
		$this->delete(SHARE_GETTOPBOARD . '1');
		$this->delete(SHARE_GETTOPBOARD . '2');
	}
	public function deleteShare($intShareId) {
		$this->delete(SHARE_GET . $intShareId);
	}
	public function deleteShareComment($intShareId, $intParentId=0) {
		$this->delete(SHARE_GETALLTOPCMT . '1');
		$this->delete(SHARE_GETALLTOPCMT . '2');
		$this->delete(SHARE_GETCOMMENT . $intShareId . $intParentId);
		$this->delete(SHARE_GETALLCOMMENT . $intShareId . $intParentId);
		if($intParentId > 0) {
			$this->delete(SHARE_GETALLCOMMENT . $intShareId . '0');
		}
	}
	public function deleteShareU($intShareId, $intType) {
		if($intType >= 0) {
			$this->delete(SHARE_GETSHAREU . $intShareId . '-1');
		}
		$this->delete(SHARE_GETSHAREU . $intShareId . $intType);
		
	}
	/** NOTIFICATION */
	public function deleteNotification($intUserId, $intSite) {
		$this->delete(NOTIFICATION_GETALL . $intUserId . '0');
		$this->delete(NOTIFICATION_GETALL . $intUserId . $intSite);
	}
	/** BEHAVIOUR */
	public function deleteBehaviour($intUserId, $intType, $intStype=0) {		
		$this->delete(BEHAVIOUR_GETALL . $intUserId . '00');
		$this->delete(BEHAVIOUR_GETALL . $intUserId . $intType . '0');
		$this->delete(BEHAVIOUR_GETALL . $intUserId . '0' . $intStype);
		$this->delete(BEHAVIOUR_GETALL . $intUserId . $intType . $intStype);
	}
	public function deleteBehaviourUread($intUserId, $intParentId, $intType) {
		$this->delete(BEHAVIOUR_UPDATEREAD . $intUserId . $intParentId . $intType);
	}
	/** UBLAST */
	public function deleteUblast($intUblastId, $intUserId=0) {
		$this->delete(UBLAST_GET . $intUblastId);
		if($intUserId > 0) {
			$this->delete(UBLAST_GETALL . $intUserId);
			$this->delete(UBLAST_GETALLRELAVANCE . $intUserId . $intUblastId);
		}
	}
	public function deleteUblastComment($intUblastId, $intBcmtId=0) {
		$this->delete(UBLAST_GETALLCOMMENT . $intUblastId);
		$this->delete(UBLAST_GETTOPCOMMENT . $intUblastId);
		if($intBcmtId > 0) {
			$this->delete(UBLAST_GETCOMMENT . $intBcmtId);
		}
	}
	public function deleteUblastU($intUblastId, $intType) {
		if($intType >= 0) {
			$this->delete(UBLAST_GETUBLASTU . $intUblastId . '-1');
		}
		$this->delete(UBLAST_GETUBLASTU . $intUblastId . $intType);
		
	}
	/** UACHIEVE */
	public function deleteUachieve($intUblastId, $intUserId=0) {
		$this->delete(UACHIEVE_GET . $intUblastId);
		if($intUserId > 0) {
			$this->delete(UACHIEVE_GETALL . $intUserId);
			$this->delete(UACHIEVE_GETALLRELAVANCE . $intUserId . $intUblastId);
		}
	}
	public function deleteUachieveComment($intUblastId, $intBcmtId=0) {
		$this->delete(UACHIEVE_GETALLCOMMENT . $intUblastId);
		$this->delete(UACHIEVE_GETTOPCOMMENT . $intUblastId);
		if($intBcmtId > 0) {
			$this->delete(UACHIEVE_GETCOMMENT . $intBcmtId);
		}
	}
	public function deleteUachieveU($intUblastId, $intType) {
		if($intType >= 0) {
			$this->delete(UACHIEVE_GETUACHIEVEU . $intUblastId . '-1');
		}
		$this->delete(UACHIEVE_GETUACHIEVEU . $intUblastId . $intType);
		
	}
}
?>
